<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/1/10
 * Time: 9:47
 */

namespace backend\controllers;

use common\business\kd\KdPerson;
use common\business\kd\KdPersonSearch;
use common\helpers\StringUtil;
use common\models\kingdee\OrgAdmin;
use Yii;
use common\business\kd\KdService;
use yii\base\Controller;
use yii\helpers\Json;

class KdController extends Controller
{
    public function actionAjaxGetListByOrg(){
        $params = Yii::$app->request->queryParams;
        $searchModel = new KdPersonSearch();

        $result = $searchModel->search4Dt($params);
        echo Json::encode($result);
    }

    public function actionIndex($id=null){
        if(StringUtil::isNullOrWhiteSpace($id)){
            $topOrg = OrgAdmin::findOne([
                'FPARENTID' => null,
            ]);
            $id = $topOrg->FID;
        }

        $searchModel = new KdPersonSearch();
        $searchModel->org_id = $id;

        return $this->render('index', [
            'searchModel' => $searchModel,
        ]);
    }
}